package org.grayrabbit.cms.util;

import org.grayrabbit.cloud.core.application.BizApplication;
import org.grayrabbit.cloud.core.biz.BizResult;
import org.grayrabbit.cloud.core.biz.ClientUtility;
import org.grayrabbit.cloud.core.biz.ObjectArgument;
import org.grayrabbit.cloud.core.module.ModuleConstructException;
import org.grayrabbit.cloud.core.module.ModuleException;
import org.grayrabbit.cloud.core.module.NoSuchModuleException;

public class RpcCmsFactory {
	private static final RpcCmsFactory instance = new RpcCmsFactory("classpath:/cmsient.xml");
	
	public static RpcCmsFactory getInstance() {
		return instance;
	}

	private BizApplication application;
	
	public RpcCmsFactory(String url){
		if(application==null)
			application = new BizApplication(url,false);
		try {
			application.run();
		} catch (ModuleConstructException e) {
		}
	}
	
	public BizResult invoke(ObjectArgument argument) throws NoSuchModuleException, ModuleException{
		return (BizResult) ClientUtility.getModule("loginclient").submit(argument);
	}
}
